package com.tencent.mapper;

import com.tencent.entity.Role;
import com.tencent.entity.User;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

@Repository
public interface LoginMapper {

    /**
     * @Description: TODO 通过登录姓名查询user
     * @author Yangjx
     * @date 2022/8/13 10:18
     * @param username
     * @return User
     */
    @Select("select * from t_user where username=#{username}")
    User findByUsername(String username);

    /**
     * @Description: TODO 基于用户id，通过用户中间表查询到该用户对应的角色id
     * @author Yangjx
     * @date 2022/8/16 10:29
     * @param userid
     * @return Integer roleId
     */
    @Select("select role_id from t_user_role where user_id=#{userid}")
    Integer findByUserId (Integer userid);

    /**
     * @Description: TODO 传入userId即可查到对应的角色，角色里有权限
     * @author Yangjx
     * @date 2022/8/13 10:26
     * @param roleId
     * @return Role
     */
    @Select("select * from t_role where id=#{roleId}")
    Role findByRoleId(Integer roleId);
}
